import { QG_QH_DATA } from "@/enum/enum-region";
import { MANANGE_PERSON_DATA } from "@/enum/enum-project";

export const QG_QH_TREE_DATA = filterQhTreeData(QG_QH_DATA);

export const MANAGER_TREE_DATA = MANANGE_PERSON_DATA;

export const BEI_JING_TREE_DATA = [
  {
    text: "11 北京市",
    name: "11 北京市",
    code: "11",
    parentId: "B5BBAB08B0694532B6DE3E296DCD579D",
    children: [
      {
        text: "1100 北京市本级",
        name: "1100 北京市本级",
        code: "1100",
        parentId: "49EE8B9DD42E4628A5B24EBE86EC2A26"
      },
      {
        text: "1101 市辖区",
        name: "1101 市辖区",
        code: "1101",
        parentId: "49EE8B9DD42E4628A5B24EBE86EC2A26",
        children: [
          {
            text: "110101 东城区",
            name: "110101 东城区",
            code: "110101",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110102 西城区",
            name: "110102 西城区",
            code: "110102",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110105 朝阳区",
            name: "110105 朝阳区",
            code: "110105",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110106 丰台区",
            name: "110106 丰台区",
            code: "110106",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110107 石景山区",
            name: "110107 石景山区",
            code: "110107",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110108 海淀区",
            name: "110108 海淀区",
            code: "110108",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110109 门头沟区",
            name: "110109 门头沟区",
            code: "110109",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110111 房山区",
            name: "110111 房山区",
            code: "110111",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110112 通州区",
            name: "110112 通州区",
            code: "110112",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110113 顺义区",
            name: "110113 顺义区",
            code: "110113",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110114 昌平区",
            name: "110114 昌平区",
            code: "110114",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110115 大兴区",
            name: "110115 大兴区",
            code: "110115",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110116 怀柔区",
            name: "110116 怀柔区",
            code: "110116",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110117 平谷区",
            name: "110117 平谷区",
            code: "110117",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110118 密云区",
            name: "110118 密云区",
            code: "110118",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          },
          {
            text: "110119 延庆区",
            name: "110119 延庆区",
            code: "110119",
            parentId: "157EAB9EA1A34D0F824E97C2C7D9F0CA"
          }
        ]
      }
    ]
  }
];

/**
 * 过滤 全国区划数据
 *
 * @param {*} treeData
 * @returns
 */
function filterQhTreeData(treeData) {
  return treeData.map(item => {
    let newItem = {
      id: item.id,
      text: item.text,
      name: item.name,
      code: item.code,
      parentId: item.parentId
    };
    if (item.children) {
      newItem.children = filterQhTreeData(item.children);
    }
    return newItem;
  });
}

function filterXmjlTreeData(treeData) {
  return treeData.map(item => {
    let newItem = {
      id: item.id,
      code: item.code,
      name: item.name,
      title: item.title,
      parentId: item.parentId,
      selectable: item.disabled ? false : true
    };
    if (item.children) {
      newItem.children = filterXmjlTreeData(item.children);
    }
    return newItem;
  });
}
